package com.nnnu.orange.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <p>
 * 记录用户预约图书的信息
 * </p>
 *
 * @author zk
 * @since 2024-11-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("reservations")
@ApiModel(value = "Reservations对象", description = "记录用户预约图书的信息")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Reservations implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "预约记录唯一标识")
    @TableId(value = "reservation_id", type = IdType.AUTO)
    private Integer reservationId;

    @ApiModelProperty(value = "用户ID（关联users表）")
    private Integer userId;

    @ApiModelProperty(value = "图书ID（关联books表）")
    private Integer bookId;

    @ApiModelProperty(value = "预约时间")
    private LocalDateTime reservationDate;

    @ApiModelProperty(value = "预约状态")
    private Integer status;

    @ApiModelProperty(value = "取书日期")
    private LocalDateTime pickUpDate;

    @ApiModelProperty(value = "记录创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @ApiModelProperty(value = "记录更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @ApiModelProperty(value = "状态说明")
    private String statusReason; // 新增字段：状态说明


    // 状态常量
    public static final int STATUS_PENDING = 0;
    public static final int STATUS_CONFIRMED = 1;
    public static final int STATUS_CANCELLED = 2;
    public static final int STATUS_COMPLETED = 3;
    public static final int STATUS_REJECTED = 4;


    //返回状态名称
    public static String getStatusDescription(int status) {
        return switch (status) {
            case STATUS_PENDING -> "待审核";
            case STATUS_CONFIRMED -> "已确认";
            case STATUS_CANCELLED -> "已取消";
            case STATUS_COMPLETED -> "已完成";
            case STATUS_REJECTED -> "被拒绝";
            default -> "未知状态";
        };
    }


}
